/*
 * Alignment styles for images, videos and iframes in editable regions
 */

/* Center (default) */
[data-editable] iframe,
[data-editable] image,
[data-editable] [data-ce-tag=img],
[data-editable] img,
[data-editable] video {
    clear: both;
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

/* Alignment styles for text in editable regions */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.post-editor {
    .tox-tinymce {
        border: none;
        opacity: 0;
        transition: opacity .25s ease-out;
        transition-delay: .5s;

        &.is-loaded {
            opacity: 1;
        }

        .tox-toolbar {           
            justify-content: center;
        }

        .tox-statusbar__path {
            display: none;
        }

        .tinymce-overlay {
            border: 3px solid var(--color-primary);
            background: rgba(var(--color-primary-rgb), .17);
            display: none;
            height: 100%;
            left: 0;
            opacity: 1;
            position: absolute;
            text-align: center;
            top: 0;
            width: 100%;
            z-index: 10000;

            & > div {
                box-shadow: 0 0 3px rgba(black, .2);
                background: var(--color-primary);
                border-radius: var(--border-radius);
                color: var(--white);
                font-size: $app-font-base;
                font-weight: var(--font-weight-semibold);
                height: auto;
                left: 50%;
                line-height: 1.5;
                padding: 1.4rem 4rem 1.4rem 3rem;
                position: absolute;
                top: 50%;
                transform: translateX(-50%) translateY(-50%);
                width: auto;
            }

            .upload-icon {               
                fill: var(--white);
                height: 2.4rem;
                margin-right: 2rem;
                width: 2.4rem;
                vertical-align: middle;
            }

            .loader {
                display: inline-block;
                height: 2.4rem;
                margin-right: 2rem;
                width: 2.4rem;

                & > span {
                    animation: spin .9s infinite linear;
                    border-top: 2px solid rgba(var(--white-rgb), 0.2);
                    border-right: 2px solid rgba(var(--white-rgb), 0.2);
                    border-bottom: 2px solid rgba(var(--white-rgb), 0.2);
                    border-left: 2px solid var(--white);
                    border-radius: 50%;
                    display: inline-block;
                    height: 2.1rem;                    
                    vertical-align: middle;
                    width: 2.1rem;

                    &::after {
                        border-radius: 50%;
                        content: "";
                        display: block;
                    }

                    @at-root {
                        @keyframes spin {
                            100% {
                                transform: rotate(360deg);
                            }
                        }
                    }
                }
            }
        }

        &.is-hovered {
            .tinymce-overlay {
                display: block;
            }
        }

        .tox-tbtn,
        .tox-panel {
            // background: var(--gray-1);
        }
        
        .tox-tbtn {
            svg {
                color: var(--icon-tertiary-color);
                fill: none;
            }
        }

        .tox-tbtn:not(span),
        .tox-split-button,
        .tox-tbtn--select {
            background: none;
            border-radius: var(--border-radius);
            border: 1px solid var(--border-light-color);
            color: var(--text-primary-color);
            height: 38px;
            margin: 2px;
            padding: 2px;
            min-width: 38px;

            &:active,
            &:focus,
            &:hover,
            &.tox-tbtn--active[aria-expanded='true'],
            &.tox-tbtn--enabled {
                background: var(--gray-6);
                border-color: var(--gray-6);

                & > button {
                    background: transparent;
                }

            }
           
        }

        .tox-split-button {
            box-shadow: none !important;
            padding: 1px;

            &:active,
            &:focus,
            &:hover {
                background: none;
                border-color: none;
            }
        }

        .tox-tbtn--select {
            padding: 2px 8px !important;
        }

        .tox-split-button__chevron {
            margin-left: 1px !important;
            min-width: 16px;
        }

        .tox-panel,
        .tox-statusbar,
        .tox-toolbar-grp {
            background: none;
            border: none;
        }

        .tox-statusbar {
            align-self: flex-end;
            bottom: 2rem;
            padding: 0;
            position: fixed;
            right: 3.2rem;
            width: auto;
        }

        .tox-toolbar-grp {
            padding-bottom: 2.4rem;
            position: relative;
        }
        
        .tox-editor-header {
            margin-bottom: 2.4rem;
        }
        
        .tox-toolbar-overlord {
            background: none;
            border: none;
            padding: 0;
        }
        
        .tox-edit-area__iframe {
            background: none;
        }
    }

    .tox-flow-layout {
        text-align: center;
    }

    .tox-path {
        float: left;
    }

    /*
     * Inline toolbar
     */

    #link-toolbar,
    #inline-toolbar {
        align-items: center;
        background: var(--popup-bg);
        border-radius: var(--border-radius);
        box-shadow: 0 5px 10px -5px var(--shadow), 4px -11px 26px -12px var(--shadow), 0 24px 50px 2px var(--shadow);
        display: none;
        min-height: 44px;
        padding: 6px;
        position: absolute;
        user-select: none;
        z-index: 10;
        
        &::after {
            border: 9px solid var(--input-bg);
            border-left-color: transparent;
            border-right-color: transparent;
            border-bottom-color: transparent;
            content: "";
            height: 18px;
            left: 50%;
            position: absolute;
            bottom: -18px;
            transform: translateX(-50%);
            width: 18px;
            z-index: 1;
        }    

        button {       
            align-items: center;
            background: transparent;
            border: none;
            cursor: pointer;
            display: inline-flex;
            height: 100%;
            justify-content: center;
            min-height: 34px;   
            margin: 0;
            outline: none;
            padding: 0;
            position: relative;
            width: 38px;
            
            // hover effect
            &::before {
               content: "";
               background: var(--gray-6); 
               border-radius: var(--border-radius);
               display: block;
               left: 50%;
               opacity: 0;
               position: absolute;
               height: 34px;
               top: 50%;
               transition: all .15s cubic-bezier(.4,0,.2,1);
               transform: scale(.5) translate(-50%, -50%);
               transform-origin: left top;
               width: 34px;
               z-index: -1;
            }

            &:hover {

               &::before {
                  opacity: 1;
                  transform: scale(1) translate(-50%, -50%);
               }
            }
           
            svg {
               color: var(--icon-tertiary-color);
               fill: none;
            }
        }

        select {
            -webkit-appearance: none;
            background: url('data:image/svg+xml;utf8,<svg fill="%238e929d" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 6"><polygon points="10 0 5 0 0 0 5 6 10 0"/></svg>') no-repeat calc(100% - 16px) 50%;
            background-color: var(--input-bg);
            background-size: 9px;
            border: none;
            border-radius: 0 !important;
            border-left: 1px solid var(--input-border-color);
            border-radius: var(--border-radius);
            box-shadow: none;
            box-sizing: content-box;
            color: var(--icon-primary-color);
            font: 400 #{$app-font-base}/1.3 var(--font-base);
            margin-left: 15px;
            max-width: 150px !important;
            min-width: 125px;
            min-height: 34px;
            outline: none;
            padding: 0 16px;
            position: relative; 
            transition: var(--transition);

            &:hover {               
                color: var(--icon-tertiary-color);
            }

            &:focus {
                box-shadow: none;
            }

            & + select {
                margin-left: 0;
            }
        }

        .tox-ico {
            color: var(--icon-primary-color);

            &:hover {
                color: var(--icon-tertiary-color);
            }
        }
    }


}

/*
 * Modal dialog and popups
 */
body {
    .tox {
        
        &-tinymce {
            border-color: var(--input-border-color);
            border-radius: var(--border-radius);
        }
        
        .tox-toolbar, 
        .tox-toolbar__overflow, 
        .tox-toolbar-overlord,
        .tox-toolbar__primary {
             background: transparent;
        }
        
        .tox-toolbar-overlord {
            border-bottom: 1px solid var(--input-border-color);
            padding: 5px;
        }
        
        &-tinymce-aux {
            z-index: 999999;
        }

        .tox-dialog {
            background-color: var(--popup-bg);
            border: none;
            border-radius: .6rem;            
            font-size: $app-font-base;
            font-weight: 400;
            min-width: 62rem;
            overflow: hidden;
            text-align: center;
            user-select: none;

            &-wrap__backdrop {
                background-color: var(--overlay);
            }

            &__header {
                background: transparent;
                padding: 4rem 4rem 0 4rem;
            }

            &__title {
                color: var(--text-primary-color);
                font-size: 1.8rem;
                font-weight: var(--font-weight-semibold);
                margin: 0 auto;
                text-align: center;
                text-transform: none;
            }

            &__footer {
                background: transparent;
                border: none;
                display: block;
                padding: 0;               

                &-end {
                    flex-direction: row-reverse;

                    .tox-button {
                        background: var(--button-bg);
                        border: none;
                        border-radius: initial;
                        box-shadow: none;
                        color: var(--white);
                        cursor: pointer;
                        display: inline-block;
                        flex: 0 1 100%;

                        font: {
                            size: 1.4rem;
                            family: var(--font-base);
                            weight: 500;
                        }

                        height: 5.6rem;
                        line-height: 5.5rem;
                        margin: 0 !important;
                        padding: 0 2rem;
                        position: relative;
                        transition: var(--transition);
                        user-select: none;
                        white-space: nowrap;

                        &:focus {
                            outline: none;
                        }

                        &:active,
                        &:focus,
                        &:hover,
                        &.button-active {
                            background: var(--button-bg-hover);
                            color: var(--white);
                        }
                        
                        &[disabled] {                           
                            cursor: not-allowed;
                        }

                        &--secondary {
                            background: var(--popup-btn-cancel-bg);
                            border: none;
                            border-top: 1px solid var(--input-border-color) !important;
                            color: var(--popup-btn-cancel-color);

                            &:active,
                            &:focus,
                            &:hover {
                                background: var(--popup-btn-cancel-bg-hover);
                                color: var(--popup-btn-cancel-hover-color);
                            }
                        }
                    }
                }
            }
            
            &__body {
                color: var(--text-primary-color);
                
                &-content {
                    padding: 3rem 4rem 5rem 4rem;
                }
                
                &-nav {
                    padding: 4rem 2rem 4rem 4rem;

                    &-item {
                        color: var(--tab-color);
                        font-size: 15px;
                        padding: 0.3rem 0.1rem;   
                        
                        &:hover {
                            color: var(--tab-active-color); 
                        }

                        &:focus {
                            background: none;
                        }

                        &--active {
                            border-color: var(--button-tertiary-bg);
                            color: var(--tab-active-color);  
                        }
                    }
                }
            }
        }

        .tox-label,
        .tox-toolbar-label {
            color: var(--label-color);
            font-size: 1.4rem;
            font-weight: var(--font-weight-semibold);
            line-height: 2.6;
        }

        .tox-checkbox__label {
            font-size: 1.4rem;
        }

        .tox-selectfield select,
        .tox-listboxfield .tox-listbox--select,
        .tox-textarea,
        .tox-textfield,
        .tox-toolbar-textfield {
            background-color: var(--input-bg);
            border: none;
            border-radius: var(--border-radius);
            box-shadow: inset 0 0 0 1px var(--input-border-color);
            color: var(--text-primary-color);
            font: 400 #{$app-font-base}/1.5 var(--font-base);
            outline: none;
            padding: 1.2rem 1.8rem;

            &:focus {
                background-color: var(--input-bg);
                box-shadow: inset 0 0 2px 1px var(--input-border-focus);
            }
        }

        .tox-listboxfield .tox-listbox--select {
            &:focus {
                background-color: var(--input-bg);
                box-shadow: inset 0 0 0 1px var(--input-border-color);
            }
        }
        
        .tox-button--naked {
            border-radius: 50%;
            color: var(--icon-secondary-color);
            transition: var(--transition);
            
            &:hover:not(:disabled) {
                background-color: var(--input-border-color);
                border-color: var(--input-border-color);
                color: var(--icon-tertiary-color) !important;
            }
            
            &[disabled] {
                background-color: transparent;
                border-color: transparent;
                color: var(--icon-secondary-color);
            }
        }   
        
        .tox-listbox__select-chevron svg {
            color: var(--icon-primary-color); 
            fill: none;
        }
        
        .tox-tbtn {
            color: var(--text-primary-color);
            cursor: pointer;
            margin: 2px 2px 3px 0;
            transition: var(--transition);
            
            svg {
                color: var(--icon-primary-color); 
                 fill: none;
            }
            
            &:active,
            &:focus,
            &:hover,
            &--enabled,
            &--enabled:hover {
                background-color: var(--gray-6);
                color: var(--text-primary-color);
                
                svg {
                    color: var(--icon-tertiary-color);
                   fill: none;
                }
            }
            
            &:focus:not(.tox-tbtn--disabled) {
                color: var(--text-primary-color);
                
                svg {
                   color: var(--icon-tertiary-color);
                   fill: none;
                }
            }  
            
            &__select-label {
                cursor: pointer;
            }
        }
        
        .tox-menu {
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-light-color);
            border-radius: var(--border-radius);
            margin-bottom: 3.2rem;
        }
        
        .tox-collection {
            
            &--toolbar {
                .tox-collection__item {
                     color: var(--icon-primary-color); 
                     border-radius: var(--border-radius);
                    
                    &--enabled {
                        background-color: var(--gray-1);
                        color: var(--color-primary);
                    }
                    
                    &--active {
                        background-color: var(--gray-1);
                        &:not(.tox-collection__item--state-disabled) {
                            color: var(--icon-tertiary-color);
                        }
                    }
                }
            }
            
            &__item {
                color: var(--text-light-color);
                
                &-caret svg {
                    color: var(--icon-primary-color); 
                    fill: none;
                }
                
                &-accessory {
                    color: var(--text-light-color);
                }

                &-checkmark,
                &-icon {
                    svg {
                        color: currentColor;
                        fill: none;
                    }
                }
            }
            
            &--list {
                .tox-collection__item--enabled {
                    background-color: var(--bg-secondary);
                    color: var(--text-primary-color);
                }
                
                .tox-collection__item--active {
                    background-color: var(--gray-1);
                    color: var(--text-primary-color);

                    &:not(.tox-collection__item--state-disabled) {
                        color: var(--icon-tertiary-color);
                    }
                }
                
                .tox-collection__item--enabled {
                    background-color: var(--input-bg-light);
                    color: var(--text-primary-color);
                }

                .tox-collection__group {
                    border-color: var(--border-light-color);
                }
            }
        }
        
       .tox-checkbox__icons {
           .tox-checkbox-icon__indeterminate svg {
              fill: var(--color-primary); 
           }
           
           .tox-checkbox-icon__unchecked svg {
               fill: none;
               stroke: currentColor;
           }
           
           .tox-checkbox-icon__checked svg {
               fill: none; 
               stroke: currentColor;
           }
        }
        
        input.tox-checkbox__input:focus+.tox-checkbox__icons {
            box-shadow: none;
        }
        
        .tox-selectfield__icon-js svg {
            fill: var(--icon-secondary-color);
        }
        
        // Tiny popups: like table toolbar or TOC refresh
        .tox-pop {
            
            &__dialog {
                background: var(--popup-bg);
                border: 1px solid var(--popup-bg);
                border-radius: 4px;
                box-shadow: 0 5px 10px -5px var(--shadow), 4px -11px 26px -12px var(--shadow), 0 24px 50px 2px var(--shadow);
            }
            
            &.tox-pop--bottom {
                &::before {
                    border-color: var(--popup-bg) transparent transparent transparent;
                }
                
                &::after {
                    border-color: var(--popup-bg) transparent transparent transparent;
                }
            }
            
            &.tox-pop--top {
                &::before {
                    border-color: transparent transparent var(--popup-bg) transparent;
                }
                
                &::after {
                    border-color: transparent transparent var(--popup-bg) transparent;
                }
            }         
            
            .tox-toolbar__group:not(:last-of-type) {
                border-color: var(--input-border-color);
            }
        }
    
        .tox-statusbar {
            background: transparent;
            border-color: var(--border-light-color);
            color: var(--text-light-color);
            padding: 13px 16px;
            text-transform: none;
            
            a, 
            &__path-item,
            &__wordcount {
               color: var(--text-light-color) !important;
            }
        }    

        .tox-color-input span {
            top: 11px;
        }

        .tox-swatches__picker-btn {

            &:hover {
               background: none;
            }

            svg {
               fill: var(--icon-tertiary-color)
            }
        }  
    }
}

/*
 * Mini WYSIWYG editor
 */
body .wysiwyg-mini-editor {
    

    .tox-toolbar-overlord {
        padding: 3px 5px;
    }

    .tox-tbtn {
        transform: scale(.9);
    }

    .tox-split-button__chevron {
        width: 16px;
    }

    .tox-tbtn--select {
        width: auto;
    }

    .tox-tbtn__select-label {
        margin: 0;
    }

    .tox-statusbar__resize-handle {
        margin-top: 4px;
    }

    .tox-statusbar__resize-handle svg {
        fill: var(--icon-secondary-color);
    }
}


/*
 * Special rules for Windows
 */

body[data-os="win"] {
    #inline-toolbar select {
        height: 4.8rem;
    }
}

.tox-label.tox-publii-text-stats {
    float: right;
    padding: 1rem 0;
    user-select: none;

    svg {
        fill: var(--gray-4);
        height: 1.6rem;
        left: 0;
        margin-right: .5rem;
        position: relative;
        top: -1px;
        width: 1.6rem;
    }

    a {
        border-bottom: 1px solid currentColor;
        color: var(--link-primary-color);
        cursor: pointer;
        transition: var(--transition);

        &:active,
        &:focus {
            color: var(--color-primary);
        }

        &:hover {
            color: $color-4;
        }

    }
}

.tinymce-iframe {
    font-size: $app-font-base;
    margin: 2rem auto;
    max-width: 1024px;
}

#tox-modal-block.tox-in {
    opacity: .35 !important;
}

.tox-window {
    border: none !important;
    border-radius: .6rem !important;
    padding: 4rem !important;

    &[role="alertdialog"] {
        padding: 4rem 4rem 1.6rem 4rem !important;
    }

    .tox-reset .tox-window-head {
        border: none;
        margin: 0 0 4rem 0;
        padding: 0 !important;
        text-transform: none;

        .tox-close {
            right: -12px !important;
            top: -8px !important;

            &:active,
            &:focus,
            &:hover {
                background: var(--white) !important;
                color: var(--icon-primary-color) !important;
            }

            i {
                color: var(--warning);
                font-size: 1.4rem !important;
            }
        }

        .tox-title {
            color: $color-4;
            font-family: var(--font-base) !important;
            font-size: 1.8rem !important;
            font-weight: 600 !important;
            text-align: center;
        }
    }

    .tox-textbox.tox-multiline {
        box-sizing: border-box;
        height: 100% !important;
        left: 0 !important;
        padding: 1.2rem 1.8rem !important;
        top: 0 !important;
        width: 100% !important;
    }

    .tox-foot {
        border: none;
        border-radius: 0 0 .6rem .6rem;
        height: 4.8rem !important;
        margin: 4rem -4rem 0 -4rem !important;
        width: auto !important;

        .tox-container-body {
            border-radius: 0 0 .6rem .6rem;
            height: 5.6rem !important;
            width: 100% !important;

            .tox-tbtn {
                background: var(--white) !important;
                border-radius: 0 0 0 .6rem !important;
                box-shadow: none !important;
                color: var(--white) !important;
                font-size: $app-font-base;
                height: 5.6rem;
                left: 0 !important;
                line-height: 5.6rem;
                top: 0 !important;
                width: 50% !important;

                &:nth-child(2):last-child {
                    width: 100% !important;
                }

                & > button {
                    font-size: $app-font-base;
                }

                &.tox-disabled > button {
                    color: var(--white) !important;
                }

                &:active,
                &:focus,
                &:hover {
                    background: lighten($color-1, 10%) !important;
                    color: var(--white) !important;
                }

                & + .tox-tbtn {
                    background: var(--white) !important;
                    border-top: 1px solid $color-8 !important;
                    border-radius: 0 0 .6rem 0 !important;
                    color: var(--gray-4) !important;
                    left: 50% !important;

                    &.tox-disabled > button {
                        color: var(--gray-4) !important;
                    }

                    &:active > button,
                    &:focus > button,
                    &:hover > button {
                        background: var(--gray-1) !important;
                        color: var(--gray-4) !important;
                    }
                }
            }
        }
    }

    .tox-textbox {
        background-color: var(--white);
        border: none;
        border-radius: var(--border-radius);
        box-shadow: inset 0 0 0 1px $color-8;
        box-sizing: border-box;
        color: var(--text-primary-color);
        font: 400 #{$app-font-base}/1.5 var(--font-base);
        height: 4.8rem;
        outline: none;
        padding: 1.2rem 1.8rem;

        &[size="3"] {
            text-align: center;
            width: 70px !important;
        }
    }

    .tox-combobox .tox-tbtn {
        & > button {
            border-radius: 0;
            line-height: 4.6rem;
            padding: 0 .8rem;

            &:active,
            &:focus,
            &:hover {
                background: $color-8;
            }
        }
    }

    .tox-listbox {
        border-radius: var(--border-radius);
        height: 48px !important;
        width: 360px !important;

        button {
            background: var(--white) !important;
            border-radius: var(--border-radius);
            height: 48px !important;
            line-height: 46px !important;
            padding: 0 1.8rem !important;
        }
    }

    label + input,
    label + div > input {
        width: 360px !important;
    }
}

@media (max-height: 900px) {
    .tox-window {
        max-height: 590px !important;
        padding: 2rem !important;

        .tox-foot {
            margin: 2.4rem -2rem 0 -2rem !important;
        }

        .tox-window-body {
            max-height: 500px;

            & > .tox-form.tox-abs-layout-item {
                max-height: 500px;

                & > .tox-container-body.tox-abs-layout {
                    max-height: 500px;
                }
            }
        }

        .tox-reset .tox-window-head {
            margin: 0 0 2rem 0 !important;
        }
    }
}
